{$CLEO .cs}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP 

script_name "RoadObjectsGTA4"

:LoadedModels
wait 100
0AF0: 1@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Loaded1"
if
1@ == 1
jf @LoadedModels
1@ = 0 
0AF1: write_int 1@ to_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Loaded1"
//models loaded


29@ = 30
28@ = 35.0
26@ = 15.0
0087: 25@ = 28@ //  radius from player 
0087: 24@ = 28@ // radius from player
25@ += 5.0
24@ += 5.0
24@ *= -1.0

6@ = 0.0
7@ = 0.0
8@ = 0.0

0AF0: 12@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_1"
0AF0: 13@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_2"
0AF0: 14@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_3"
0AF0: 15@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_4"
0AF0: 16@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_5"
0AF0: 17@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_6"
0AF0: 18@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_7"
0AF0: 19@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_8"
0AF0: 20@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_9"
0AF0: 21@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_10"
0AF0: 22@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_11"
0AF0: 23@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_12"

0AF0: 9@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_13"
0AF0: 10@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_14"
0AF0: 11@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_15"
0AF0: 27@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_16"

0AF0: 4@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_17"
0AF0: 5@ = read_int_from_ini_file "cleo\RoadObjectsGTA4.ini" section "Models" key "Rub_18"
wait 10


while true
wait 150
if
   Player.Defined($PLAYER_CHAR)
then
    08D3: get_present_zone_popcycle_group_for_peds_and_cars_to 1@
    if and
        not 1@ == 5
        not 1@ == 14
        not 1@ == 7
        not 1@ == 8
        not 1@ == 4
        not 1@ == 2
        not 1@ == 9
    then
        06AC: 1@ = actor $PLAYER_ACTOR movement_speed
        if and
            $ACTIVE_INTERIOR == 0
            $ONMISSION == 0
            1@ < 30.0
        then

            28@ = 0
            2@ = 0
            while 0EA9: get_any_object_no_save_recursive 28@ progress_to 28@ object_to 0@
                if
                    09CC:   object 0@ model_is 2966
                then
                    if
                        0EE6: locate_char_distance_to_object $PLAYER_ACTOR object 0@ radius 50.0
                    then
                        2@ += 1
                    end
                end
            end

            if
                2@ >= 20
            then
                wait 5000
                continue
            end

            28@ = 30.0
            04C4: store_coords_to 6@ 7@ 8@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
            0209: 2@ = random_int_in_ranges 1 3
            if
                2@ == 1
            then
                0208: 2@ = random_float_in_ranges -30.0 30.0
                04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset 2@ 40.0 0.0
            else
                0EB2: get_offset_from_camera_in_world_coords 0.0 -10.0 0.0 store_to 1@ 2@ 3@
                28@ = 10.0
            end

            02C0: store_to 1@ 2@ 3@ ped_path_coords_closest_to 1@ 2@ 3@
            if
                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 45.0
            then

                0208: 0@ = random_float_in_ranges -3.5 3.5
                if 0@ >= 0.0
                then 005B: 1@ += 0@  // (float)
                else 0063: 1@ -= 0@  // (float)
                end

                0208: 0@ = random_float_in_ranges -3.5 3.5
                if 0@ >= 0.0
                then 005B: 2@ += 0@  // (float)
                else 0063: 2@ -= 0@  // (float)
                end

                if and
                    not locate_camera_distance_to_coordinates 1@ 2@ 3@ radius 28@
                    not locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 28@
                then
                    gosub @Create_Obj
                end
            end
        end
    end
end
end


:Create_Obj
// create object for render
3@ += 2.0
model.Load(2966)
038B: load_requested_models
0E01: create_object_no_save 2966 at 1@ 2@ 3@ offset 0 ground 1 to 0@
0382: set_object 0@ collision_detection 0
model.Destroy(2966)
0208: 1@ = random_float_in_ranges 0.0 360.0
0177: set_object 0@ Z_angle_to 1@
0209: 2@ = random_int_in_ranges 1 19
if
2@ == 1
then
0F04: create_render_object_to_object_from_special 0@ special_model 12@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 2
then
0F04: create_render_object_to_object_from_special 0@ special_model 13@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 3
then
0F04: create_render_object_to_object_from_special 0@ special_model 14@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 4
then
0F04: create_render_object_to_object_from_special 0@ special_model 15@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 5
then
0F04: create_render_object_to_object_from_special 0@ special_model 16@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 6
then
0F04: create_render_object_to_object_from_special 0@ special_model 17@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 7
then
0F04: create_render_object_to_object_from_special 0@ special_model 18@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 8
then
0F04: create_render_object_to_object_from_special 0@ special_model 19@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 9
then
0F04: create_render_object_to_object_from_special 0@ special_model 20@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 10
then
0F04: create_render_object_to_object_from_special 0@ special_model 21@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 11
then
0F04: create_render_object_to_object_from_special 0@ special_model 22@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 12
then
0F04: create_render_object_to_object_from_special 0@ special_model 23@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 13
then
0F04: create_render_object_to_object_from_special 0@ special_model 9@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 14
then
0F04: create_render_object_to_object_from_special 0@ special_model 10@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 15
then
0F04: create_render_object_to_object_from_special 0@ special_model 11@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 16
then
0F04: create_render_object_to_object_from_special 0@ special_model 27@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 17
then
0F04: create_render_object_to_object_from_special 0@ special_model 4@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
if
2@ == 18
then
0F04: create_render_object_to_object_from_special 0@ special_model 5@ offset 0 0 0.035 rotation 0 0 0 store_to 31@
end
08D2: object 0@ scale_model 0
01C4: remove_references_to_object 0@ // This object will now disappear when the player looks away
0@ = -1
31@ = -1
return


//rub1 -  
//rub2 -  
//rub3 -  
//rub4 -  
//rub5 -   
//rub6 -  
//rub7 -  
//rub8 -   
//rub9 -  
//rub10 -  
//rub11 -  
//rub12 -  
//rub13 - 
//rub14 - 
//rub15 - 
//rub16 -  
//rub17 - 
//rub18 - 

//rub19 -  
//rub20 -   2

//rub21 -  
//rub22 -  


// By ArtemQa146